import request from './request'

export const getBusinessList = (params) => {
  return request({
    url: '/business',
    method: 'get',
    params
  })
}

export const createBusiness = (data) => {
  return request({
    url: '/business/create',
    method: 'post',
    data
  })
}

export const updateBusiness = (data) => {
  return request({
    url: `/business/${data.id}`,
    method: 'put',
    data
  })
}

export const deleteBusiness = (id) => {
  return request({
    url: `/business/${id}`,
    method: 'delete'
  })
}

export const getBusinessDetail = (id) => {
  return request({
    url: `/business/${id}`,
    method: 'get'
  })
}

export const exportBusiness = () => {
  return request({
    url: '/business/export',
    method: 'get',
    responseType: 'blob'
  })
}

export const importBusiness = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  return request({
    url: '/business/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}